<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition  template="template.xhtml"    >

	<ui:define name="principal">
	 
		<h:form id="frmCadastroServico">
		
   			<p:growl id="message" 
			         showDetail="true" 
			         globalOnly="true"
			         sticky="false"
			         life="1200" />		
			         		
			<p:panel header="#{msg['label.servico.nome.tela']}" 
			         styleClass="pnFormularioCadastro">
				<h:panelGrid columns="1" >
					<p:outputLabel value="#{msg['label.servico.servico']}" />
					<p:inputText id="servico"
					             value="#{cadastroServicoMB.servico.descServico}"
					             size="45"
					             required="true"
					             requiredMessage="#{msg['mensagem.obrigatoria']}">
						<p:message for="servico" />		
					</p:inputText>	
					
					<p:outputLabel value="#{msg['label.servico.sigla']}" />
					<p:inputText id="sigla"
					             value="#{cadastroServicoMB.servico.siglaServico}"
					             size="45"
					             required="true"
					             requiredMessage="#{msg['mensagem.obrigatoria']}">
						<p:message for="sigla" />		
					</p:inputText>	
					
					<p:outputLabel id="tempo" 
					               value="#{msg['label.servico.tempo']}" />
					<p:column>
						<h:panelGrid columns="3">
						<p:spinner id="hora"
						           value="#{cadastroServicoMB.servico.tempoAtendimentoHora}"
								   min="0"
								   max="23"
								   maxlength="2"
								   size="5"		 >
							<p:message for="hora" />		
						</p:spinner>
						<p:outputLabel value=" : " />
						<p:spinner id="minuto"
						           value="#{cadastroServicoMB.servico.tempoAtendimentoMinuto}"
								   min="0"
								   max="59"
								   maxlength="2"
								   size="5"		
								   stepFactor="5" >
							<p:message for="minuto" />		
						</p:spinner>						
						</h:panelGrid>
					</p:column>
					
					<p:outputLabel value="#{msg['label.servico.valor.custo']}" />
					<p:inputText id="custo"
					             value="#{cadastroServicoMB.servico.valorCusto}"
					             size="45"
					             required="true"
					             requiredMessage="#{msg['mensagem.obrigatoria']}">
						<f:convertNumber pattern="###,##0.00"/>
						<p:message for="custo" />		
					</p:inputText>	
					
					<p:outputLabel value="#{msg['label.servico.valor.venda']}" />
					<p:inputText id="venda"
					             value="#{cadastroServicoMB.servico.valorVenda}"
					             size="45"
					             required="true"
					             requiredMessage="#{msg['mensagem.obrigatoria']}"> 
						<f:convertNumber pattern="###,##0.00"/>
						<p:message for="venda" />		
					</p:inputText>	

							            
				</h:panelGrid>
				<h:panelGrid columns="1"
			      	         styleClass="pgBotoes" >
					<p:column>
						<p:commandButton value="Salvar"
						 				 update=":frmCadastroServico, :frmListagemServico"
								         action="#{cadastroServicoMB.salva()}"   />
						<p:spacer width="20" height="0"/>
						<p:commandButton value="Limpar"
						 				 update=":frmCadastroServico"
						 				 immediate="true">
							<p:resetInput target=":frmCadastroServico" />								         
						</p:commandButton>
						<p:spacer width="20" height="0"/>
						<p:commandButton value="Fechar"
						                 immediate="true"
						                 action="agenda" />
					</p:column>
				</h:panelGrid>						
			</p:panel>
		</h:form>
		
		<h:form id="frmListagemServico">
			<p:panel header="Serviços Cadastrados" styleClass="pnFormularioCadastro" >
				<p:dataTable id="tbServico" 
				             value="#{cadastroServicoMB.listaServico}" 
				             var="reg"
				             paginator="true"
				             rows="10"
				             paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				             rowsPerPageTemplate="5,10,15,20,25,30"
				             emptyMessage="Nenhum registro Encontrado" >
					<p:column headerText="Serviço"
					          width="10%">
						<p:outputLabel value="#{reg.idServico}" />
					</p:column>	
					<p:column headerText="Descriçao"
					          width="50%">
						<p:outputLabel value="#{reg.descServico}"/>
					</p:column>	
					<p:column headerText="Sigla"
					          width="15%">
						<p:outputLabel value="#{reg.siglaServico}"/>
					</p:column>	
					<p:column headerText="Tempo"
					          width="10%">
 						<p:outputLabel value="#{reg.tempoAtendimentoHora}:#{reg.tempoAtendimentoMinuto}" />
					</p:column>
					<p:column headerText="Ações"
							  style="align: center;"		
					          width="15%">
						<p:commandLink action="cadastroServicoProduto" >														            
							<h:graphicImage library="imagens" 
											name="novo.png"
											title="Adicionar Produto" />
							<f:param name="idServico" value="#{reg.idServico}" />
						</p:commandLink>
						<p:spacer width="8" />
						<p:commandLink update=":frmCadastroServico">														            
							<h:graphicImage library="imagens" 
											name="editar.png"
											title="Editar" />
							<f:setPropertyActionListener target="#{cadastroServicoMB.servico}" value="#{reg}" />
						</p:commandLink>
						<p:spacer width="8" />
						<p:commandLink oncomplete="PF('dlgExcluiServico').show()" >		
							<h:graphicImage library="imagens" 
											name="excluir.png"
											title="Deletar" />
							<f:setPropertyActionListener target="#{cadastroServicoMB.servico}" value="#{reg}" />
						</p:commandLink>
					</p:column>	
				</p:dataTable>
			</p:panel>
		</h:form>
		
		<p:dialog widgetVar="dlgExcluiServico"  >
			<p:outputLabel value="Confirma a Exclusão do Serviço?" />
			<br />
			<br />
			<p:commandButton value="Sim"
			                 action="#{cadastroServicoMB.exclui()}"
			                 update=":frmListagemServico :frmCadastroServico:message"
			                 oncomplete="PF('dlgExcluiServico').hide()" />
			<p:spacer width="5px" />
			<p:commandButton value="Não"
			                 oncomplete="PF('dlgExcluiServico').hide()" />
		</p:dialog>				
		
	</ui:define>
</ui:composition>
</html>